package com.springboot.dubbo.book.service;

import com.springboot.dubbo.base.po.oracle.CallRingMsg;
import com.springboot.dubbo.book.mapper.ICallRingMsgMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClassName CallRingMsgServiceImpl
 * @Description: 这里是写数据库操作的业务逻辑
 * @Author 杨冬冬
 * @Date 2021/7/2 0002 17:43
 **/
@Service
public class CallRingMsgServiceImpl {

    @Autowired
    private ICallRingMsgMapper iCallRingMsgMapper;

    /*
     * @Author 杨冬冬
     * @Description 分布式事务测试
     * @Date 18:04 2021/7/2 0002
     * @param
     **/
    public void insert() throws Exception {
        CallRingMsg callRingMsg = new CallRingMsg();
        callRingMsg.setAgentId("测试1");
        callRingMsg.setBindId("测试1");
        callRingMsg.setCallId("测试1" + new Date().getTime());
        callRingMsg.setCallNo("测试1");
        callRingMsg.setCustomData("测试1");
        callRingMsg.setPeerNo("测试1");
        callRingMsg.setRingTime(new Date());
        callRingMsg.setInsertDate(new Date());

        //int random = (int) (Math.random() * (2 - 1) + 1);
        //if (random == 1) {
        //    throw new Exception("插入失败");
        //}
        iCallRingMsgMapper.insert(callRingMsg);
    }
}
